/*
 * @lc app=leetcode.cn id=101 lang=javascript
 *
 * [101] 对称二叉树
 */

// @lc code=start
/**
 * Definition for a binary tree node.
 * function TreeNode(val, left, right) {
 *     this.val = (val===undefined ? 0 : val)
 *     this.left = (left===undefined ? null : left)
 *     this.right = (right===undefined ? null : right)
 * }
 */
/**
 * @param {TreeNode} root
 * @return {boolean}
 */
var isSymmetric = function(root) {
    const check = function(left,right) {
        if(left == null && right == null) {
            return true;
        }
        if(left && right) {
            return left.val == right.val && check(left.left,right.right) && check(left.right,right.left)
        }
        return false; // 一个子树存在一个不存在，肯定不对称
    }
    return check(root.left,root.right);
};

// @lc code=end

